package com.gzist.springailab03.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.time.Duration;


/**
 * 测试接口类
 */
@RestController
@RequiredArgsConstructor
public class UserController {

    private final ChatModel chatModel;

    private final ToolCallbackProvider toolCallbackProvider;
    @GetMapping("/test")
    public String test1(@RequestParam("userInput") String userInput) {
        ChatClient chatClient = ChatClient.builder(chatModel).build();
        return chatClient.prompt()
                .user(userInput)
                .tools(toolCallbackProvider.getToolCallbacks())
                .call()
                .content();
    }

}
